package com.eneat.smartrule.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 算术操作符枚举
 */
@Getter
@AllArgsConstructor
public enum ArithmeticOperatorEnum {
    ADD("+", "加法"),
    SUBTRACT("-", "减法"),
    MULTIPLY("*", "乘法"),
    DIVIDE("/", "除法"),
    MOD("%", "取模");

    private final String code;
    private final String desc;

    public static ArithmeticOperatorEnum fromCode(String code) {
        for (ArithmeticOperatorEnum op : values()) {
            if (op.getCode().equals(code)) {
                return op;
            }
        }
        throw new IllegalArgumentException("未知的算术操作符: " + code);
    }
}
